﻿/* ***********************************************************************************************
 * Oak_DynamicSeek
 * Version: 1.0
 * Author:  BRyan Solero  
 * Email:  arindil@gmail.com
 * Copyright 2012.  All Rights Reserved.
 * 
 * ************************************************************************************************/
using System;
using Microsoft.Xna.Framework;

namespace OakEngine.AI.Dynamic_Steering_Behavior
{
  public class Oak_DynamicFlee : Oak_DynBehavior
  {
      private Vector2 m_Target;
      private float m_fSpeed;

      #region Prop
      public Vector2 Target { get { return m_Target; } set { m_Target = value; } }
      public float Speed { get { return m_fSpeed; } set { m_fSpeed = value; } } 
      #endregion

      #region Constructor
      public Oak_DynamicFlee()
      {
          m_Target = Vector2.Zero;
          m_fSpeed = 0.0f;
      }
      public Oak_DynamicFlee(Vector2 target)
      {
          m_Target = target;
          m_fSpeed = 0.0f;
      }
      public Oak_DynamicFlee(Vector2 target, float speed)
      {
          m_Target = target;
          m_fSpeed = speed;
      } 
      #endregion

      #region Method
      public override void UpdateSteeringMovement(Steering.Oak_Steering steer)
      {
          steer.ForwardVector = this.BehaviorAgent.Position;
          steer.ForwardVector -= m_Target;

          if (OakEngine.AI.Tools.OAK_AITools.SquareMagnitude(steer.ForwardVector) > 0)
          {
              steer.ForwardVector = Vector2.Normalize(steer.ForwardVector);
              steer.ForwardVector *= m_fSpeed;

          }
      } 
      #endregion
    }
}
